package com.mfin.bom.objects;

// Generated 17 Jun, 2012 11:27:33 PM by Hibernate Tools 3.4.0.CR1
import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.mfin.enumeration.LoanStatus;

/**
 * FinanceLoan generated by hbm2java
 */
@Entity
@Table(name = "finance_loan", catalog = "mfindb")
public class FinanceLoan implements java.io.Serializable {

	private Long id;
	private Customer customer;
	private Finance finance;
	private Partner partner;
	private LoanMaster loanMaster;
	private Date loanDate;
	private Double loanAmount;
	private Integer duration;
	private Double interest;
	private Double docCharges;
	private Date duedate;
	private Double installment;
	private Boolean security;
	private String secDetails;
	private LoanStatus loanStatus;
	private Set<Customer> guarantors = new HashSet<Customer>(0);
	private Vehicle vehicle;
	private Set<Cashbook> cashbooks = new HashSet<Cashbook>(0);

	public FinanceLoan() {
	}

	public FinanceLoan(Customer customer, Finance finance, Partner partner,
			LoanMaster loanMaster, Date loanDate, Double loanAmount,
			Integer duration, Double interest, Double docCharges, Date duedate,
			Double installment, Boolean security, String secDetails,
			LoanStatus loanStatus, Set<Customer> guarantors,
			Vehicle vehicle, Set<Cashbook> cashbooks) {
		this.customer = customer;
		this.finance = finance;
		this.partner = partner;
		this.loanMaster = loanMaster;
		this.loanDate = loanDate;
		this.loanAmount = loanAmount;
		this.duration = duration;
		this.interest = interest;
		this.docCharges = docCharges;
		this.duedate = duedate;
		this.installment = installment;
		this.security = security;
		this.secDetails = secDetails;
		this.loanStatus = loanStatus;
		this.guarantors = guarantors;
		this.vehicle = vehicle;
		this.cashbooks = cashbooks;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CUSTOMER_ID")
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FINANCE_ID")
	public Finance getFinance() {
		return this.finance;
	}

	public void setFinance(Finance finance) {
		this.finance = finance;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PARTNER_ID")
	public Partner getPartner() {
		return this.partner;
	}

	public void setPartner(Partner partner) {
		this.partner = partner;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "LOAN_TYPE")
	public LoanMaster getLoanMaster() {
		return this.loanMaster;
	}

	public void setLoanMaster(LoanMaster loanMaster) {
		this.loanMaster = loanMaster;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LOAN_DATE", length = 19)
	public Date getLoanDate() {
		return this.loanDate;
	}

	public void setLoanDate(Date loanDate) {
		this.loanDate = loanDate;
	}

	@Column(name = "LOAN_AMOUNT", precision = 22, scale = 0)
	public Double getLoanAmount() {
		return this.loanAmount;
	}

	public void setLoanAmount(Double loanAmount) {
		this.loanAmount = loanAmount;
	}

	@Column(name = "DURATION")
	public Integer getDuration() {
		return this.duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	@Column(name = "INTEREST", precision = 22, scale = 0)
	public Double getInterest() {
		return this.interest;
	}

	public void setInterest(Double interest) {
		this.interest = interest;
	}

	@Column(name = "DOC_CHARGES", precision = 22, scale = 0)
	public Double getDocCharges() {
		return this.docCharges;
	}

	public void setDocCharges(Double docCharges) {
		this.docCharges = docCharges;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DUEDATE", length = 19)
	public Date getDuedate() {
		return this.duedate;
	}

	public void setDuedate(Date duedate) {
		this.duedate = duedate;
	}

	@Column(name = "INSTALLMENT", precision = 22, scale = 0)
	public Double getInstallment() {
		return this.installment;
	}

	public void setInstallment(Double installment) {
		this.installment = installment;
	}

	@Column(name = "SECURITY", columnDefinition = "BIT")
	public Boolean getSecurity() {
		return this.security;
	}

	public void setSecurity(Boolean security) {
		this.security = security;
	}

	@Column(name = "SEC_DETAILS", length = 100)
	public String getSecDetails() {
		return this.secDetails;
	}

	public void setSecDetails(String secDetails) {
		this.secDetails = secDetails;
	}

	@Column(name = "LOAN_STATUS", length = 13)
	@Enumerated(EnumType.STRING)
	public LoanStatus getLoanStatus() {
		return this.loanStatus;
	}

	public void setLoanStatus(LoanStatus loanStatus) {
		this.loanStatus = loanStatus;
	}

	// @OneToMany(fetch = FetchType.LAZY, mappedBy = "financeLoan")
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "Guarantor", joinColumns = { @JoinColumn(name = "FINANCE_LOAN_ID") }, inverseJoinColumns = { @JoinColumn(name = "GUARANTOR_ID") })
	public Set<Customer> getGuarantors() {
		return this.guarantors;
	}

	public void setGuarantors(Set<Customer> guarantors) {
		this.guarantors = guarantors;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "financeLoan")
	public Vehicle getVehicle() {
		return this.vehicle;
	}

	public void setVehicles(Vehicle vehicle) {
		this.vehicle = vehicle;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "financeLoan")
	public Set<Cashbook> getCashbooks() {
		return this.cashbooks;
	}

	public void setCashbooks(Set<Cashbook> cashbooks) {
		this.cashbooks = cashbooks;
	}

}
